class Solution:
    def addStrings(self, num1: str, num2: str) -> str:
        r=""
        if len(num1) < len(num2):
            num1,num2 = num2,num1
        nextOne = 0
        for i in range(1,len(num2)+1):
            next = int(num1[len(num1) - i]) + int(num2[len(num2) - i]) + nextOne
            nextOne = next//10
            r = str(next%10)+r
        for i in range(len(num1)-len(num2)-1,-1,-1):
            next = int(num1[i]) + nextOne
            nextOne = next // 10
            r = str(next % 10) + r
        if nextOne == 1:
            r = "1" + r
        return r


if __name__ == '__main__':
    so = Solution()
    num1 = "1"
    num2 = "9"
    r = so.addStrings(num1, num2)
    print(r)
